import {Component, OnInit, Inject} from '@angular/core';
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material';
// import {OverlayContainer} from '@angular/cdk/overlay';
@Component({
  selector: 'app-new-project',
  templateUrl: './new-project.component.html',
  styleUrls: ['./new-project.component.scss']
})
export class NewProjectComponent implements OnInit {
  title = '';
  project: any;

  constructor(
    @Inject(MAT_DIALOG_DATA)
    private data,  // 获取触发对话框组件传过来的数据（需要通过令牌来实现注入）

    private dialogRef: MatDialogRef<NewProjectComponent>, // 关闭对话框并返回数据时需要用到的数据
    // private oc: OverlayContainer
  ) {
  }

  ngOnInit() {
    this.title = this.data.title;
    this.project = this.data.project ? this.data.prject : 'unassigned';
    console.log(JSON.stringify(this.data.project)); // 打印获取到的数据
    // this.oc.themeClass = this.data.dark ? 'myapp-dark-theme' : null;
  }

  onCloseNewProjectDialog() {
    // 关闭对话框，关闭的同时会向打开对话框的组件传递数据
    this.dialogRef.close(`I received your message.`);
  }
}
